from langchain_community.chat_models import ChatOpenAI
from langchain.prompts.chat import (
    ChatPromptTemplate,
    SystemMessagePromptTemplate,
    HumanMessagePromptTemplate,
)
template = "你是一个翻译助理 ,请将用户输入的内容由{input_language}直接翻译为{output_language}."
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template = "{text}"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)

openai_api_key = 'EMPTY'
openai_base_base = 'http://localhost:11434/v1'
chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])
chat = ChatOpenAI(model_name="deepseek-r1:latest",openai_api_key = openai_api_key,openai_api_base= openai_base_base,temperature=0,max_tokens=256)

print(chat.invoke(chat_prompt.format_prompt(input_language="英语", output_language="中文",
                 text="Artificial Intelligence (AI) will have a profound impact on human civilization in the coming years. ").to_messages()))